﻿CKEDITOR.dialog.add("lightbox",function(c){var g=CKEDITOR.plugins.link,f=c.lang.common,e=c.lang.link;return{title:"Lightbox",minWidth:350,minHeight:300,contents:[{id:"info",label:e.info,title:e.info,elements:[{type:"vbox",id:"urlOptions",children:[{type:"hbox",widths:"0",children:[{type:"text",id:"url",label:c.lang.lightbox.url,required:!0,onLoad:function(){this.allowOnChange=!0},onKeyUp:function(){this.allowOnChange=!1;/^((javascript:)|[#\/\.\?])/i.test(this.getValue());this.allowOnChange=!0},onChange:function(){if(this.allowOnChange)this.onKeyUp();
$(".cke_dialog .ImagePreview").html('<img src="'+this.getValue()+'" style="max-height:100px; max-width:450px;"/>')},validate:function(){this.getDialog();return!c.config.linkJavaScriptLinksAllowed&&/javascript\:/.test(this.getValue())?(alert(f.invalidValue),!1):this.getDialog().fakeObj?!0:CKEDITOR.dialog.validate.notEmpty(e.noUrl).apply(this)},setup:function(a){this.allowOnChange=!1;a.url&&this.setValue(void 0!=a.url.protocol?a.url.protocol+a.url.url:a.url.url);this.allowOnChange=!0},onShow:function(){$(".cke_dialog .ImagePreview").html('<img src="'+
this.getValue()+'" style="max-height:100px; max-width:450px;"/>')},commit:function(a){a.type="url";a.url||(a.url={});a.url.protocol="";a.advanced.advCSSClasses="ckelightbox ckelightboxgallery"+gal;this.onChange();a.url||(a.url={});a.url.url=this.getValue();this.allowOnChange=!1}},{type:"button",id:"browse",hidden:"true",style:"margin-top:16px;",filebrowser:"info:url",label:f.browseServer}]},{id:"prev",type:"html",html:c.lang.lightbox.preview+'<div class="ImagePreview" style="border:2px solid black; height:100px; text-align:center;"></div>'},
{type:"text",label:c.lang.lightbox.title,requiredContent:"a[title]","default":"",id:"advTitle",setup:function(a){a.advanced&&this.setValue(a.advanced[this.id]||"")},commit:function(a){a.advanced||(a.advanced={});a.advanced[this.id]=this.getValue()||""}},{type:"text",label:c.lang.lightbox.gallery,"default":"",id:"advRel",setup:function(a){a.advanced||(a.advanced={});gal=a.advanced.advCSSClasses;gal=gal.split("ckelightboxgallery");gal=gal[1];a.advanced&&this.setValue(gal||"")},commit:function(){gal=
this.getValue()||""}}]}]}],onShow:function(){$(".cke_dialog .ImagePreview").html("");var a=this.getParentEditor(),c=a.getSelection(),b=null;(b=g.getSelectedLink(a))&&b.hasAttribute("href")?c.getSelectedElement()||c.selectElement(b):b=null;a=g.parseLinkAttributes(a,b);this._.selectedElement=b;this.setupContent(a)},onOk:function(){var a={};this.commitContent(a);var d=c.getSelection(),b=g.getLinkAttributes(c,a);if(this._.selectedElement){var a=this._.selectedElement,e=a.data("cke-saved-href"),f=a.getHtml();
a.setAttributes(b.set);a.removeAttributes(b.removed);e==f&&(a.setHtml(b.set["data-cke-saved-href"]),d.selectElement(a));delete this._.selectedElement}else d=d.getRanges()[0],d.collapsed&&(a=new CKEDITOR.dom.text(b.set["data-cke-saved-href"],c.document),d.insertNode(a),d.selectNodeContents(a)),b=new CKEDITOR.style({element:"a",attributes:b.set}),b.type=CKEDITOR.STYLE_INLINE,b.applyToRange(d,c),d.select()}}});